package ɱɱɱ;


import java.io.*;

public class B_08_excavator {

   public static void main(String[] args) throws IOException {
       StreamTokenizer in = new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in)));
       in.nextToken();
       int n = (int) in.nval,max = 0,len,sch = 0;
       int[] score = new int[n];
       while(0 < n--) {
           in.nextToken();
           int schoo = (int) in.nval;
           in.nextToken();
           int sco = (int) in.nval;
           score[schoo] += sco;
       }
       len = score.length;
       for(int i = 1 ; i < len ; i++) {
           if(score[i] > max) {
               max = score[i];
               sch = i;
           }
       }
       System.out.print(sch + " " + max);
   }
}
